<template>
  <section class="payment-guide">
    <div class="container">
      <!-- 头部区域 -->
      <div class="guide-header">
        <span class="subtitle">{{ $t('payment.subtitle') }}</span>
        <h2 class="title">{{ $t('payment.title') }}</h2>
        <p class="description">
          {{ $t('payment.description') }}
        </p>
      </div>

      <!-- 支付方式选择 -->
      <div class="payment-methods">
        <div 
          class="method-card" 
          :class="{ active: activeMethod === 'wechat' }"
          @click="activeMethod = 'wechat'"
        >
          <div class="method-icon wechat-icon">
            <wechat theme="outline" size="36" fill="#ffffff" />
          </div>
          <h3>{{ $t('payment.wechat.title') }}</h3>
          <p>{{ $t('payment.wechat.description') }}</p>
        </div>
        
        <div 
          class="method-card" 
          :class="{ active: activeMethod === 'alipay' }"
          @click="activeMethod = 'alipay'"
        >
          <div class="method-icon alipay-icon">
            <alipay theme="outline" size="36" fill="#ffffff" />
          </div>
          <h3>{{ $t('payment.alipay.title') }}</h3>
          <p>{{ $t('payment.alipay.description') }}</p>
        </div>
      </div>

      <!-- 设置步骤 -->
      <div class="setup-steps">
        <div class="steps-header">
          <h3>{{ $t('payment.steps.title') }}</h3>
          <div class="step-progress">
            <div 
              v-for="step in totalSteps" 
              :key="step"
              class="progress-dot"
              :class="{ active: currentStep >= step }"
            ></div>
          </div>
        </div>

        <!-- 微信支付设置步骤 -->
        <div v-if="activeMethod === 'wechat'" class="steps-content">
          <div class="step" v-show="currentStep === 1">
            <div class="step-number">1</div>
            <div class="step-content">
              <h4>{{ $t('payment.steps.wechat.step1.title') }}</h4>
              <p>{{ $t('payment.steps.wechat.step1.desc') }}</p>
              <div class="step-image wechat-download">
                <div class="mock-app-store">
                  <div class="app-icon wechat-color">
                    <wechat theme="filled" size="40" fill="#ffffff" />
                  </div>
                  <div class="app-info">
                    <h5>WeChat</h5>
                    <p>Tencent Inc.</p>
                    <button class="download-btn">
                      <download-one theme="outline" size="16" :stroke-width="3" />
                      DOWNLOAD
                    </button>
                  </div>
                </div>
              </div>
            </div>
          </div>

          <div class="step" v-show="currentStep === 2">
            <div class="step-number">2</div>
            <div class="step-content">
              <h4>{{ $t('payment.steps.wechat.step2.title') }}</h4>
              <p>{{ $t('payment.steps.wechat.step2.desc') }}</p>
              <div class="step-image">
                <div class="mock-screen wechat-color">
                  <div class="screen-header">
                    <div class="header-title">Register</div>
                  </div>
                  <div class="screen-body">
                    <div class="form-group">
                      <label>
                        <phone theme="outline" size="16" :stroke-width="3" />
                        Phone Number
                      </label>
                      <div class="input-control">+1 XXX-XXX-XXXX</div>
                    </div>
                    <div class="form-group">
                      <button class="action-btn">
                        <mail theme="outline" size="16" :stroke-width="3" />
                        Get Verification Code
                      </button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>

          <div class="step" v-show="currentStep === 3">
            <div class="step-number">3</div>
            <div class="step-content">
              <h4>{{ $t('payment.steps.wechat.step3.title') }}</h4>
              <p>{{ $t('payment.steps.wechat.step3.desc') }}</p>
              <div class="step-image">
                <div class="mock-screen wechat-color">
                  <div class="screen-header">
                    <div class="header-title">Add Card</div>
                  </div>
                  <div class="screen-body">
                    <div class="form-group">
                      <label>
                        <bank-card theme="outline" size="16" :stroke-width="3" />
                        Card Number
                      </label>
                      <div class="input-control">XXXX XXXX XXXX XXXX</div>
                    </div>
                    <div class="form-group">
                      <label>
                        <calendar theme="outline" size="16" :stroke-width="3" />
                        Expiry Date
                      </label>
                      <div class="input-control">MM/YY</div>
                    </div>
                    <div class="form-group">
                      <label>
                        <lock theme="outline" size="16" :stroke-width="3" />
                        CVV
                      </label>
                      <div class="input-control">XXX</div>
                    </div>
                    <div class="form-group">
                      <button class="action-btn">
                        <add theme="outline" size="16" :stroke-width="3" />
                        Add Card
                      </button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>

          <div class="step" v-show="currentStep === 4">
            <div class="step-number">4</div>
            <div class="step-content">
              <h4>{{ $t('payment.steps.wechat.step4.title') }}</h4>
              <p>{{ $t('payment.steps.wechat.step4.desc') }}</p>
              <div class="step-image">
                <div class="mock-screen wechat-color">
                  <div class="screen-header">
                    <div class="header-title">Identity Verification</div>
                  </div>
                  <div class="screen-body">
                    <div class="form-group">
                      <label>
                        <user theme="outline" size="16" :stroke-width="3" />
                        Full Name
                      </label>
                      <div class="input-control">John Doe</div>
                    </div>
                    <div class="form-group">
                      <label>
                        <id-card theme="outline" size="16" :stroke-width="3" />
                        ID Type
                      </label>
                      <div class="input-control">Passport</div>
                    </div>
                    <div class="form-group">
                      <label>
                        <id-card theme="outline" size="16" :stroke-width="3" />
                        ID Number
                      </label>
                      <div class="input-control">XXXXXXXXX</div>
                    </div>
                    <div class="form-group">
                      <button class="action-btn">
                        <check theme="outline" size="16" :stroke-width="3" />
                        Verify
                      </button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 支付宝设置步骤 -->
        <div v-else class="steps-content">
          <div class="step" v-show="currentStep === 1">
            <div class="step-number">1</div>
            <div class="step-content">
              <h4>{{ $t('payment.steps.alipay.step1.title') }}</h4>
              <p>{{ $t('payment.steps.alipay.step1.desc') }}</p>
              <div class="step-image">
                <div class="mock-app-store">
                  <div class="app-icon alipay-color">
                    <alipay theme="filled" size="40" fill="#ffffff" />
                  </div>
                  <div class="app-info">
                    <h5>Alipay</h5>
                    <p>Ant Financial Services</p>
                    <button class="download-btn">
                      <download-one theme="outline" size="16" :stroke-width="3" />
                      DOWNLOAD
                    </button>
                  </div>
                </div>
              </div>
            </div>
          </div>

          <div class="step" v-show="currentStep === 2">
            <div class="step-number">2</div>
            <div class="step-content">
              <h4>{{ $t('payment.steps.alipay.step2.title') }}</h4>
              <p>{{ $t('payment.steps.alipay.step2.desc') }}</p>
              <div class="step-image">
                <div class="mock-screen alipay-color">
                  <div class="screen-header">
                    <div class="header-title">Register</div>
                  </div>
                  <div class="screen-body">
                    <div class="form-group">
                      <label>
                        <phone theme="outline" size="16" :stroke-width="3" />
                        Phone Number
                      </label>
                      <div class="input-control">+1 XXX-XXX-XXXX</div>
                    </div>
                    <div class="form-group">
                      <button class="action-btn">
                        <mail theme="outline" size="16" :stroke-width="3" />
                        Get Verification Code
                      </button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>

          <div class="step" v-show="currentStep === 3">
            <div class="step-number">3</div>
            <div class="step-content">
              <h4>{{ $t('payment.steps.alipay.step3.title') }}</h4>
              <p>{{ $t('payment.steps.alipay.step3.desc') }}</p>
              <div class="step-image">
                <div class="mock-screen alipay-color">
                  <div class="screen-header">
                    <div class="header-title">Add Card</div>
                  </div>
                  <div class="screen-body">
                    <div class="form-group">
                      <label>
                        <bank-card theme="outline" size="16" :stroke-width="3" />
                        Card Number
                      </label>
                      <div class="input-control">XXXX XXXX XXXX XXXX</div>
                    </div>
                    <div class="form-group">
                      <label>
                        <calendar theme="outline" size="16" :stroke-width="3" />
                        Expiry Date
                      </label>
                      <div class="input-control">MM/YY</div>
                    </div>
                    <div class="form-group">
                      <label>
                        <lock theme="outline" size="16" :stroke-width="3" />
                        CVV
                      </label>
                      <div class="input-control">XXX</div>
                    </div>
                    <div class="form-group">
                      <button class="action-btn">
                        <add theme="outline" size="16" :stroke-width="3" />
                        Add Card
                      </button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>

          <div class="step" v-show="currentStep === 4">
            <div class="step-number">4</div>
            <div class="step-content">
              <h4>{{ $t('payment.steps.alipay.step4.title') }}</h4>
              <p>{{ $t('payment.steps.alipay.step4.desc') }}</p>
              <div class="step-image">
                <div class="mock-screen alipay-color">
                  <div class="screen-header">
                    <div class="header-title">Identity Verification</div>
                  </div>
                  <div class="screen-body">
                    <div class="form-group">
                      <label>
                        <user theme="outline" size="16" :stroke-width="3" />
                        Full Name
                      </label>
                      <div class="input-control">John Doe</div>
                    </div>
                    <div class="form-group">
                      <label>
                        <id-card theme="outline" size="16" :stroke-width="3" />
                        ID Type
                      </label>
                      <div class="input-control">Passport</div>
                    </div>
                    <div class="form-group">
                      <label>
                        <id-card theme="outline" size="16" :stroke-width="3" />
                        ID Number
                      </label>
                      <div class="input-control">XXXXXXXXX</div>
                    </div>
                    <div class="form-group">
                      <button class="action-btn">
                        <check theme="outline" size="16" :stroke-width="3" />
                        Verify
                      </button>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- 步骤控制按钮 -->
        <div class="step-controls">
          <button 
            class="step-btn prev" 
            @click="prevStep"
            :disabled="currentStep === 1"
          >
            <left theme="outline" size="16" :stroke-width="3" />
            {{ $t('payment.steps.prev') }}
          </button>
          <button 
            class="step-btn next" 
            @click="nextStep"
            :disabled="currentStep === totalSteps"
          >
            {{ $t('payment.steps.next') }}
            <right theme="outline" size="16" :stroke-width="3" />
          </button>
        </div>
      </div>

      <!-- 使用提示 -->
      <div class="usage-tips">
        <h3>{{ $t('payment.tips.title') }}</h3>
        <div class="tips-grid">
          <div class="tip-card">
            <div class="tip-icon">
              <bank-card theme="filled" size="36" fill="#00c389" />
            </div>
            <h4>{{ $t('payment.tips.cards.title') }}</h4>
            <p>{{ $t('payment.tips.cards.desc') }}</p>
          </div>
          <div class="tip-card">
            <div class="tip-icon">
              <shield theme="filled" size="36" fill="#00c389" />
            </div>
            <h4>{{ $t('payment.tips.security.title') }}</h4>
            <p>{{ $t('payment.tips.security.desc') }}</p>
          </div>
          <div class="tip-card">
            <div class="tip-icon">
              <exchange theme="filled" size="36" fill="#00c389" />
            </div>
            <h4>{{ $t('payment.tips.exchange.title') }}</h4>
            <p>{{ $t('payment.tips.exchange.desc') }}</p>
          </div>
          <div class="tip-card">
            <div class="tip-icon">
              <wallet theme="filled" size="36" fill="#00c389" />
            </div>
            <h4>{{ $t('payment.tips.offline.title') }}</h4>
            <p>{{ $t('payment.tips.offline.desc') }}</p>
          </div>
        </div>
      </div>

      <!-- 常见问题 -->
      <div class="faq-section">
        <h3>{{ $t('payment.faq.title') }}</h3>
        <div class="faq-list">
          <div 
            v-for="(faq, index) in faqs" 
            :key="index"
            class="faq-item"
            :class="{ active: activeFaq === index }"
            @click="toggleFaq(index)"
          >
            <div class="faq-question">
              <h4>
                <help theme="outline" size="18" :stroke-width="3" class="faq-icon" />
                {{ faq.question }}
              </h4>
              <span class="toggle-icon">{{ activeFaq === index ? '−' : '+' }}</span>
            </div>
            <div class="faq-answer" v-show="activeFaq === index">
              <p>{{ faq.answer }}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
</template>

<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { 
  Wechat, Alipay, DownloadOne, Phone, Mail, 
  BankCard, Calendar, Lock, Add, User, IdCard, 
  Check, Left, Right, Exchange,
  Shield, Wallet, Help
} from '@icon-park/vue-next';

const { t } = useI18n();

// 支付方式选择
const activeMethod = ref('wechat');

// 步骤控制
const currentStep = ref(1);
const totalSteps = 4;

const nextStep = () => {
  if (currentStep.value < totalSteps) {
    currentStep.value++;
  }
};

const prevStep = () => {
  if (currentStep.value > 1) {
    currentStep.value--;
  }
};

// FAQ控制
const activeFaq = ref(null);

const toggleFaq = (index) => {
  activeFaq.value = activeFaq.value === index ? null : index;
};

// FAQ数据
const faqs = ref([
  {
    question: t('payment.faq.q1.question'),
    answer: t('payment.faq.q1.answer')
  },
  {
    question: t('payment.faq.q2.question'),
    answer: t('payment.faq.q2.answer')
  },
  {
    question: t('payment.faq.q3.question'),
    answer: t('payment.faq.q3.answer')
  },
  {
    question: t('payment.faq.q4.question'),
    answer: t('payment.faq.q4.answer')
  }
]);
</script>

<style scoped>
.payment-guide {
  padding: 80px 0;
  background-color: #f8fafc;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 头部样式 */
.guide-header {
  text-align: center;
  margin-bottom: 60px;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.8s forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.subtitle {
  font-size: 1.2rem;
  color: #00c389;
  font-weight: 600;
  display: block;
  margin-bottom: 16px;
}

.title {
  font-size: 2.5rem;
  color: #1e293b;
  margin-bottom: 20px;
}

.description {
  max-width: 800px;
  margin: 0 auto;
  color: #64748b;
  font-size: 1.1rem;
  line-height: 1.6;
}

/* 支付方式选择 */
.payment-methods {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 60px;
  opacity: 0;
  animation: fadeIn 0.8s 0.3s forwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.method-card {
  flex: 1;
  max-width: 400px;
  padding: 30px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.method-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 12px rgba(0, 0, 0, 0.1);
}

.method-card.active {
  border: 2px solid #00c389;
  background-color: #f0fdf4;
}

.method-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
}

.wechat-icon {
  background-color: #07C160;
}

.alipay-icon {
  background-color: #00A0E9;
}

.method-card h3 {
  font-size: 1.5rem;
  color: #1e293b;
  margin-bottom: 10px;
}

.method-card p {
  color: #64748b;
  font-size: 1rem;
}

/* 设置步骤 */
.setup-steps {
  background: white;
  border-radius: 12px;
  padding: 40px;
  margin-bottom: 60px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  opacity: 0;
  animation: fadeIn 0.8s 0.6s forwards;
}

.steps-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

.steps-header h3 {
  font-size: 1.5rem;
  color: #1e293b;
}

.step-progress {
  display: flex;
  gap: 8px;
}

.progress-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #e2e8f0;
  transition: all 0.3s;
}

.progress-dot.active {
  background-color: #00c389;
}

.step {
  display: flex;
  gap: 30px;
  align-items: flex-start;
}

.step-number {
  width: 40px;
  height: 40px;
  background-color: #00c389;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 600;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
}

.step-content h4 {
  font-size: 1.3rem;
  color: #1e293b;
  margin-bottom: 16px;
}

.step-content p {
  color: #64748b;
  margin-bottom: 20px;
  line-height: 1.6;
}

.step-image {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

/* 模拟App Store页面 */
.mock-app-store {
  background: white;
  display: flex;
  padding: 20px;
  border-radius: 8px;
}

.app-icon {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  margin-right: 20px;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.wechat-color {
  background-color: #07C160;
}

.alipay-color {
  background-color: #00A0E9;
}

.app-info {
  flex: 1;
}

.app-info h5 {
  margin: 0 0 5px;
  font-size: 1.1rem;
  color: #1e293b;
}

.app-info p {
  margin: 0 0 10px;
  color: #64748b;
  font-size: 0.9rem;
}

.download-btn {
  background: #f1f5f9;
  border: none;
  padding: 8px 16px;
  border-radius: 16px;
  font-weight: bold;
  color: #1e293b;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 模拟手机屏幕 */
.mock-screen {
  border-radius: 8px;
  overflow: hidden;
}

.screen-header {
  height: 50px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.screen-body {
  background: white;
  padding: 20px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 5px;
}

.input-control {
  background: #f1f5f9;
  padding: 10px 15px;
  border-radius: 6px;
  color: #1e293b;
  font-size: 0.9rem;
}

.action-btn {
  width: 100%;
  padding: 12px;
  background: #00c389;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  margin-top: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.step-controls {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 40px;
}

.step-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 30px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.step-btn.prev {
  background-color: #f1f5f9;
  color: #64748b;
  border: none;
}

.step-btn.next {
  background-color: #00c389;
  color: white;
  border: none;
}

.step-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 使用提示 */
.usage-tips {
  margin-bottom: 60px;
  opacity: 0;
  animation: fadeIn 0.8s 0.9s forwards;
}

.usage-tips h3 {
  text-align: center;
  font-size: 1.5rem;
  color: #1e293b;
  margin-bottom: 40px;
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
}

.tip-card {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  text-align: center;
  transition: all 0.3s ease;
}

.tip-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.1);
}

.tip-icon {
  font-size: 2.5rem;
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  transition: all 0.3s ease;
}

.tip-card:hover .tip-icon {
  transform: scale(1.2);
}

.tip-card h4 {
  font-size: 1.2rem;
  color: #1e293b;
  margin-bottom: 12px;
}

.tip-card p {
  color: #64748b;
  line-height: 1.6;
}

/* FAQ部分 */
.faq-section {
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  opacity: 0;
  animation: fadeIn 0.8s 1.2s forwards;
}

.faq-section h3 {
  text-align: center;
  font-size: 1.5rem;
  color: #1e293b;
  margin-bottom: 40px;
}

.faq-list {
  max-width: 800px;
  margin: 0 auto;
}

.faq-item {
  border-bottom: 1px solid #e2e8f0;
  transition: all 0.3s ease;
}

.faq-item.active {
  background-color: #f8fafc;
  padding: 0 15px;
  margin: 0 -15px;
  border-radius: 8px;
}

.faq-question {
  padding: 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.faq-question h4 {
  font-size: 1.1rem;
  color: #1e293b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.faq-item:hover .faq-question h4 {
  color: #00c389;
}

.faq-icon {
  color: #00c389;
  transition: all 0.3s ease;
}

.toggle-icon {
  font-size: 1.5rem;
  color: #64748b;
  transition: all 0.3s ease;
}

.faq-item.active .faq-icon {
  transform: rotate(360deg);
}

.faq-answer {
  padding: 0 0 20px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.3s ease;
}

.faq-item.active .faq-answer {
  max-height: 300px;
  opacity: 1;
  padding: 10px 0 20px;
}

.faq-answer p {
  color: #64748b;
  line-height: 1.6;
  margin: 0;
  padding-left: 28px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .payment-methods {
    flex-direction: column;
    align-items: center;
  }

  .method-card {
    width: 100%;
    max-width: 100%;
  }

  .step {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .step-number {
    margin-bottom: 20px;
  }

  .tips-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .title {
    font-size: 2rem;
  }

  .description {
    font-size: 1rem;
  }

  .setup-steps,
  .faq-section {
    padding: 20px;
  }

  .step-image {
    max-width: 100%;
  }
}
</style> 